feat: add pre-commit hook support #1250#1264
Conversation
Signed-off-by: zine yu <zine.xlws@gmail.com>
Signed-off-by: zine yu <zine.xlws@gmail.com>
Signed-off-by: zine yu <zine.xlws@gmail.com>
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Signed-off-by: zine yu <zine.xlws@gmail.com>
Signed-off-by: zine yu <zine.xlws@gmail.com>
|
@genedna 已经修改了部分代码,应该能够通过所有测试了 |
There was a problem hiding this comment.
Pull Request Overview
This PR implements pre-commit hook support for the libra merge command as requested in issue #1250. It adds the ability to run pre-commit hooks during the commit process and provides a --disable-pre flag to temporarily disable pre-commit execution.
- Adds pre-commit hook infrastructure with template files for both Unix/Linux (.sh) and Windows (.ps1) systems
- Integrates pre-commit hook execution into the commit command with proper error handling and platform-specific execution
- Updates all test files to disable pre-commit hooks during testing to maintain test isolation
Reviewed Changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| libra/src/command/commit.rs | Core implementation of pre-commit hook execution with platform-specific command handling |
| libra/src/command/init.rs | Creates hooks directory and installs default pre-commit template files during repository initialization |
| libra/src/utils/path.rs | Adds utility function to get hooks directory path |
| libra/template/pre-commit.sh | Default Unix/Linux pre-commit hook template |
| libra/template/pre-commit.ps1 | Default Windows PowerShell pre-commit hook template |
| libra/tests/command/*.rs | Updates test files to disable pre-commit hooks during testing |
| aria/contents/docs/libra/command/commit/index.mdx | Documentation update for the new --disable-pre flag |
| @@ -0,0 +1,12 @@ | |||
|
|
|||
| #!/bin/sh | |||
There was a problem hiding this comment.
The shebang line #!/bin/sh is incorrect for a PowerShell script. PowerShell scripts should not have a shebang line, or if needed for cross-platform compatibility, should use a PowerShell-specific shebang like #!/usr/bin/env pwsh.
| #!/bin/sh | |
| #!/usr/bin/env pwsh |
| /// add signed-off-by line at the end of the commit message | ||
| #[arg(short = 's', long)] | ||
| pub signoff: bool, | ||
|
|
There was a problem hiding this comment.
The disable_pre argument is missing documentation. Add a doc comment to explain its purpose, similar to other arguments in the struct.
| /// disable pre-commit hooks or checks |
| panic!("fatal: no changes added to commit, use --allow-empty to override"); | ||
| } | ||
|
|
||
| // run pre commit hook |
There was a problem hiding this comment.
The comment has a grammatical error. It should be "run pre-commit hook" (with hyphen) to match the terminology used elsewhere in the codebase.
| // run pre commit hook | |
| // run pre-commit hook |
此 PR 完成了 r2cn 测试任务 #1250 ,为libra merge 命令 实现pre-commit hook,并提供 --disable-pre flag以临时禁止pre-commit的执行